{	Problem: http://codeforces.ru/problemset/problem/9/C
	Verdict: Accepted
}
uses SysUtils;
var n,t:longint;
function b(n:longint):longint;
var s,t:string; i:longint;
begin
s:='';
while n>0 do begin
  s:=s+chr(n mod 2+48);
  n:=n div 2;
end;
t:='';
for i:=length(s) downto 1 do t:=t+s[i];
result:=strtoint(t);
end;
begin
read(n);
t:=1;
while b(t)<=n do inc(t);
write(t-1);
end.